package com.bdqn.jd;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class PlayerAspect {
    @Pointcut("execution(public void updateEquip(..))")
    public void pointcut(){

    }


    @Before("pointcut()")
    public void before(JoinPoint jp){
        Object[] objects = jp.getArgs();
        Equip equip = (Equip) objects[0];
        if(equip.getType().equals("指环")){
            equip.setName("紫色梦幻"+equip.getName());
            equip.setAttackPlus(equip.getAttackPlus()+6);
            equip.setDefencePlus(equip.getDefencePlus()+6);
        }
    }

    @AfterReturning(pointcut = "pointcut()",returning = "returnValue")
    public void afterReturning(JoinPoint jp,Object returnValue){
        System.out.println("装备升级成功");
    }

}
